HOST_OPENOCD := MIMXRT106x
NAME         := mcu_mimxrt106x

$(NAME)_MBINS_TYPE := kernel
$(NAME)_VERSION    := 1.0.1
$(NAME)_SUMMARY    := driver & sdk for platform/mcu mimxrt106x Release Version: 2.5.0

$(NAME)_COMPONENTS += arch_armv7m
$(NAME)_COMPONENTS += rhino newlib_stub

GLOBAL_CFLAGS += -DA_LITTLE_ENDIAN

ifeq ($(COMPILER),armcc)
GLOBAL_CFLAGS += --c99 --cpu=Cortex-M7.fp.dp --apcs=/hardfp --fpu=fpv5_d16 -g --split_sections --apcs=interwork

GLOBAL_ASMFLAGS += --cpu=Cortex-M7.fp.dp --apcs=interwork --apcs=/hardfp  --fpu=fpv5_d16 -g

GLOBAL_LDFLAGS += -L --cpu=Cortex-M7.fp.dp                    \
                  -L --fpu=fpv5_d16                 \
                  -L --apcs=/hardfp                     \
                  -L --strict                           \
                  -L --xref -L --callgraph -L --symbols \
                  -L --info=sizes -L --info=totals -L --info=unused -L --info=veneers -L --info=summarysizes
else ifeq ($(COMPILER),iar)
GLOBAL_CFLAGS += --cpu=Cortex-M7  \
                 --cpu_mode=thumb \
                 --endian=little
else
GLOBAL_CFLAGS += -mcpu=cortex-m7           \
                 -mlittle-endian           \
                 -mthumb                   \
                 -mfloat-abi=hard          \
                 -mfpu=fpv5-d16            \
                 -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin  -mapcs -std=gnu99 -Wno-format -Wno-incompatible-pointer-types

GLOBAL_CFLAGS += -D__VFP_FP__

$(NAME)_CFLAGS += -Werror -Wno-unused-variable -Wno-unused-parameter -Wno-implicit-function-declaration
$(NAME)_CFLAGS += -Wno-type-limits -Wno-sign-compare -Wno-pointer-sign -Wno-uninitialized
$(NAME)_CFLAGS += -Wno-return-type -Wno-unused-function -Wno-unused-but-set-variable
$(NAME)_CFLAGS += -Wno-unused-value -Wno-strict-aliasing

GLOBAL_ASMFLAGS += -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mthumb -mapcs -std=gnu99
GLOBAL_ASMFLAGS += -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16

GLOBAL_LDFLAGS += --specs=nano.specs --specs=nosys.specs
GLOBAL_LDFLAGS += -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mthumb -mapcs -std=gnu99
GLOBAL_LDFLAGS += -Xlinker --gc-sections -Xlinker -static -Xlinker -z -Xlinker muldefs
GLOBAL_LDFLAGS += -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16
endif

GLOBAL_CFLAGS += -D__STARTUP_CLEAR_BSS
GLOBAL_CFLAGS += -D__STARTUP_INITIALIZE_NONCACHEDATA

GLOBAL_CFLAGS += -D__RT106X_WITH_BOOT

# Common source
$(NAME)_SOURCES := drivers/fsl_clock.c  \
                   drivers/fsl_common.c \
                   drivers/fsl_gpio.c   \
                   drivers/fsl_lpuart.c \
                   drivers/fsl_flexcan.c \
                   drivers/fsl_flexspi.c \
                   drivers/fsl_cache.c   \
                   hal/hal_uart.c       \
		           hal/hal_gpio.c      \
                   hal/hal_can.c      \
                   hal/hal_flash.c      \
                   aos/aos.c            \
                   aos/soc_impl.c       \
                   drivers/fsl_wdog.c

GLOBAL_INCLUDES += ./      \
                   drivers \
                   CMSIS/Include \
		   hal

EXTRA_TARGET_MAKEFILES +=  $($(HOST_MCU_FAMILY)_LOCATION)/gen_image_bin.mk
